<?php
/**
 * Description of YCommon_Express_CodeMap
 *
 * @author kaixin
 */
class YCommon_Express_CodeMap {
    public static $expressCodeMap = array(
        'shunfeng' => '顺丰',
        'shentong' => '申通',
        'ems' => 'EMS',
        'ems' => 'ems',
        'yuantong' => '圆通',
        'zhongtong' => '中通',
        'rufengda' => '如风达',
        'yunda' => '韵达',
        'tiantian' => '天天',
        'huitongkuaidi' => '汇通',
        'quanfengkuaidi' => '全峰',
        'debangwuliu' => '德邦',
        'zhaijisong' => '宅急送',
        'youzhengguonei' => '平邮',
    );
    
    public function getExpressCodeByName($name)
    {
        if (in_array(substr($name, 0, 4), self::$expressCodeMap))
        {
            self::$expressCodeMap = array_flip(self::$expressCodeMap);
            return array(self::$expressCodeMap[substr($name, 0, 4)], substr($name, 4));
        }
        elseif (in_array(substr($name, 0, 6), self::$expressCodeMap))
        {
            self::$expressCodeMap = array_flip(self::$expressCodeMap);
            return array(self::$expressCodeMap[substr($name, 0, 6)], substr($name, 6));
        }
        elseif (in_array(substr($name, 0, 3), self::$expressCodeMap))
        {
            self::$expressCodeMap = array_flip(self::$expressCodeMap);
            return array(self::$expressCodeMap[substr($name, 0, 3)], substr($name, 3));
        }
        else
        {
            return null;
        }
    }
}

?>
